//
//  MirrorMaterial.cpp
//  RayTracer
//
//  Created by 俞云康 on 3/25/16.
//  Copyright © 2016 yushroom. All rights reserved.
//

#include "MirrorMaterial.hpp"
#include "Params.hpp"

shared_ptr<Material> MirrorMaterial::create(const Params& params) {
    std::shared_ptr<Texture> Kr = Texture::create(params.child("texture"));
    return  make_shared<MirrorMaterial>(Kr);
}

//std::shared_ptr<BxDF> MirrorMaterial::get_brdf(const HitInfo& hit) const {
//    Color R = Kr->sample(hit.texcoord.x, hit.texcoord.y);
//    return std::make_shared<SpecularReflection>(&hit, R, std::make_shared<FresnelNoOp>());
//}

shared_ptr<BSDF> MirrorMaterial::getBSDF(const HitInfo& hit) const {
    auto bsdf = std::make_shared<BSDF>(hit, hit.normal);
    Color R = Kr->sample(hit.texcoord);
    bsdf->add(new SpecularReflection(&hit, R, std::make_shared<FresnelNoOp>()));
    return bsdf;
}
